//
//  LocationPermissionView.m
//  markmap
//
//  Created by 甘世清 on 2024/4/17.
//

#import "LocationPermissionView.h"

@implementation LocationPermissionView
+(void)SQ_Show:(UIView*)superView{
    if ([SQCLLocationManager sharedManager].authorizationStatus != kCLAuthorizationStatusDenied ){
        return;
    }
    LocationPermissionView * vc = [[LocationPermissionView alloc]initWithFrame:CGRectMake(0, 0, 320, 280)];
    LSTPopView * pop = [LSTPopView initWithCustomView:vc
                                           parentView:superView
                                             popStyle:LSTPopStyleFade dismissStyle:LSTDismissStyleCardDropToLeft];
    pop.hemStyle = LSTHemStyleCenter;
    pop.bgAlpha = 0.3;
    [pop pop];
    LSTPopViewWK(pop)
    [vc.noBtn setTouchBlock:^(SQCustomButton * _Nonnull button) {
        [wk_pop dismiss];
    }];
    [vc.yesBtn setTouchBlock:^(SQCustomButton * _Nonnull button) {
        [wk_pop dismiss];
        NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
        if ([[UIApplication sharedApplication] canOpenURL:url]) {
            [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
            }];
        }
    }];
}

- (void)SQ_UIViewForSelfView{
    UIImageView * bgImage = [[UIImageView alloc]init];
    bgImage.image = SQGetImage(@"编组 6");
    [self addSubview:bgImage];
    [bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    UILabel * top = [[UILabel alloc]init];
    top.text = SQNSLocalString(@"打开定位权限\n体验更佳！");
    top.numberOfLines = 0;
    top.font = FONT_MEDIUM(20);
    top.textColor = SQColor333333;
    [self addSubview:top];
    [top mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(30);
        make.top.equalTo(self).offset(25);
    }];
    
    UILabel * top2 = [[UILabel alloc]init];
    top2.text = SQNSLocalString(@"1.定位权限开启，更精准推荐！\n2.获取位置信息，享受个性化服务！\n3.开启定位权限，探索更多精彩！");
    top2.numberOfLines = 0;
    top2.font = FONT_REGULAR(15);
    top2.textColor = SQColor333333;
    [self addSubview:top2];
    [top2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(40);
        make.right.equalTo(self.mas_right).offset(-40);
        make.top.equalTo(self).offset(110);
    }];
    
    
    
    
    
    [self addSubview:self.noBtn];
    [self.noBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(117);
        make.height.mas_equalTo(40);
        make.left.equalTo(self).offset(30);
        make.bottom.equalTo(self.mas_bottom).offset(-33);
    }];
    [self addSubview:self.yesBtn];
    [self.yesBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(117);
        make.height.mas_equalTo(40);
        make.right.equalTo(self.mas_right).offset(-30);
        make.bottom.equalTo(self.mas_bottom).offset(-33);
    }];
    
}

- (SQCustomButton *)yesBtn{
    if (!_yesBtn) {
        _yesBtn = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(0, 0) midmargin:0];
        _yesBtn.SQBackimageView.image = SQGetImage(@"矩形备份 2");
        _yesBtn.text = SQNSLocalString(@"立即开启");
        _yesBtn.textColor = UIColor.whiteColor;
        _yesBtn.font = FONT_MEDIUM(16);
    }
    return _yesBtn;
}
- (SQCustomButton *)noBtn{
    if (!_noBtn) {
        _noBtn = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(0, 0) midmargin:0];
        _noBtn.text = SQNSLocalString(@"暂不开启");
        _noBtn.layer.cornerRadius = 20;
        _noBtn.layer.masksToBounds = YES;
        _noBtn.layer.borderColor = SQColor(@"#979797").CGColor;
        _noBtn.layer.borderWidth = 1;
        _noBtn.textColor = SQColor999999;
        _noBtn.font = FONT_MEDIUM(16);
    }
    return _noBtn;

}
 
@end
